import React from 'react';
import classNames from 'classnames';
import './index.less';

export default class BackNav extends React.Component {

  back = () => {
    if (this.props.to) {
      __self.history.push('/')
      return;
    }
    __self.history.goBack()
  }

  render() {
    const { title, hideBackButton = false } = this.props;
    return (
      (
        <div className={classNames( "header-nav", { 'text-center': hideBackButton })}>
          {
            !hideBackButton &&
            <a onClick={this.back} className="header-back">返回</a>
          }
          <span>{title}</span>
          {
            !hideBackButton && <span />
          }

        </div>
      )
    )
  }
}

